<?php
require_once dirname(__FILE__) . '/../common/Common.php';
require_once dirname(__FILE__) . '/../dao/dao_live/dao_live.class.php';

class RequestSignIn extends AbstractInterface//申请主播
{
    public function initialize()
    {
        return true;
    }

    public function verifyInput(&$args)
    {
        $req = $args['interface']['para'];

        $rules = array(
            'userid' => array('type' => 'string'),
            'name' => array('type' => 'string'),
            'card1' => array('type' => 'string'),
            'card2' => array('type' => 'string'),
            'idnumber' => array('type' => 'string'),
            'industry' => array('type' => 'int'),
            'type' => array('type' => 'int'),
            'license' => array('type' => 'string'),
            'purpose' => array('type' => 'string'),
            'intro' => array('type' => 'string'),
        );
        return $this->_verifyInput($args, $rules);
    }

    public function process()
    {
        interface_log(INFO, EC_OK, "RequestSignIn args=" . var_export($this->_args, true));
        $config = getConf('ROUTE.DB');
        $dao_live = new dao_live($config['HOST'], $config['PORT'], $config['USER'], $config['PASSWD'], $config['DBNAME']);
        $error_message = "";

        if($dao_live->CheckExisting('sign_in','userid',$this->_args['userid'])){
            $error_message="db error:userid existing";
            $this->_retMsg = 'RegUser::process() fail';
            return false;
        }

        $ret = $dao_live->AddSignIn($this->_args);

        if ($ret != 0) {
            $this->_retValue = $ret;
            $error_message = "db error:no permission";
            $this->_retMsg = 'RequestSignIn::process() fail ' . genErrMsg($this->_retValue);
            return false;
        }

        $this->_retValue = EC_OK;
        $this->_data ="";
        interface_log(INFO, EC_OK, 'RequestSignIn::process() succeed');
        return true;
    }
}

?>
